"use client";

import { Inter } from "next/font/google";
import "./globals.css";
import { SessionProvider } from 'next-auth/react';
import { usePathname } from 'next/navigation';
import { Toaster } from "@/components/ui/toaster"
import { LanguageProvider } from '@/contexts/LanguageContext';
import Navbar from "../components/layout/Navbar";

const inter = Inter({ subsets: ["latin"] });

// Define structured data
const structuredData = {
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "name": "Prompt Minder",
      "url": "https://prompt-minder.com",
      "logo": "https://prompt-minder.com/logo.png",
      "sameAs": []
    },
    {
      "@type": "WebSite",
      "name": "Prompt Minder",
      "url": "https://prompt-minder.com",
      "potentialAction": {
        "@type": "SearchAction",
        "target": "https://prompt-minder.com/search?q={search_term_string}",
        "query-input": "required name=search_term_string"
      }
    }
  ]
};

export default function RootLayout({ children }) {
  const pathname = usePathname();
  
  const noHeaderFooterPages = ['/sign-in', '/sign-up','/','/'];
  const shouldShowHeaderFooter = !noHeaderFooterPages.includes(pathname);

  return (
    <SessionProvider>
      <LanguageProvider>
        <html>
          <head>
            <script
              type="application/ld+json"
              dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}
            />
          </head>
          <body className={inter.className} suppressHydrationWarning>
            <div className="min-h-screen flex flex-col">
              {shouldShowHeaderFooter && <Navbar />}
              <main className="flex-1">
                {children}
              </main>
            </div>
            <Toaster />
          </body>
        </html>
      </LanguageProvider>
    </SessionProvider>
  );
}
